package dubo;

import java.lang.invoke.VarHandle;
import java.util.Arrays;
import java.util.HashMap;

import java.util.Random;
import java.util.Scanner;

public class dubo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[3];
        HashMap<String, Integer> map = new HashMap<>();
        map.put("gamer1", 100000);
        int ci=0;
        while (true) {
            System.out.println("专家:请下注");
            int money = sc.nextInt();
            if (money <= map.get("gamer1")) {
                System.out.println("下注成功");
                if (ci==0){
                map.put("gamer1",100000-money );
                ci++;
                }
                else {
                    map.put("gamer1",(map.get("gamer1")-money));
                }
                Integer hymoney = map.get("gamer1");
                System.out.println("game1剩下的本金为:" + hymoney);
                System.out.println("1:大   2：小   3：豹子");
                int choose = sc.nextInt();
                int Number=shaizi(arr);
                result(choose,Number,map,money,hymoney);
            }else{
                System.out.println("系统提示：你的资金不足");
                Integer sxmoney = map.get("gamer1");
                System.out.println("gamer1玩家资金为:"+sxmoney);
            }
            if(map.get("gamer1")<=0){
                System.out.println("game over");
                System.exit(0);
            }

        }

    }

    public static int shaizi(int[] arr) {
        Random r = new Random();
        for (int i = 0; i < 3; i++) {
            arr[i] = r.nextInt(6) + 1;
        }
        System.out.println(Arrays.toString(arr));
        int Number;
      if(arr[0]==arr[1]&&arr[1]==arr[2]){
          Number=3;
      }else if(arr[0]+arr[1]+arr[2]>9){
          Number=1;
      }else{
          Number=2;
      }
      return Number;
    }
    public static void result(int choose,int Number,  HashMap<String, Integer> map,int money,int hymoney){
        if(choose==Number){
            if (Number==1){
                System.out.println("恭喜，赢得本次对局，本次对局结果为大(赔率为1：2)");
                map.put("gamer1",hymoney+money*2);
                System.out.println(map);
            }else if(Number==2){
                System.out.println("恭喜，赢得本次对局，本次对局结果为小(赔率为1：2)");
                map.put("gamer1",hymoney+money*2);
                System.out.println(map);
            }else{
                System.out.println("恭喜，赢得本次对局，本次对局结果为豹子(赔率为1：6)");
                map.put("gamer1",hymoney+money*6);
                System.out.println(map);
            }
        }else{
            System.out.println("很遗憾，请继续加油");
            map.put("gamer1",hymoney);
            System.out.println(map);
        }
    }
}
